<script>
  $(function () {
    function empty(str) {
      return str == null || str == '';
    }


    $('#loginForm').submit(function (event) {
      var username = $('#usernameInput').val();
      if (empty(username)) {
        alert('用户名不能为空');
        return false;
      }
      var password = $('#passwordInput').val();
      if (empty(password)) {
        alert('密码不能为空');
        return false;
      }
      var email = $('#emailInput').val();
      if (empty(email)) {
        alert('邮箱不能为空');
        return false;
      }
      return true;
    });
  });
</script>

<form id="loginForm" class="search-form-middle text-center" action="/register" method="POST">
  <p>用户名：<input id="usernameInput" name="username" type="text"/></p>

  <p>密码&nbsp;&nbsp;&nbsp;&nbsp;：<input id="passwordInput" name="password" type="password"/></p>

  <p>邮箱&nbsp;&nbsp;&nbsp;&nbsp;：<input id="emailInput" name="email" type="email"/></p>

  <p><input class="btn btn-default" name="go" type="submit" value="注册"></p>
</form>